﻿using Learun.Util;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
using SqlSugar;
using System;
namespace Learun.Application.TwoDevelopment.ZZDT_EC

{
    /// <summary>
    /// 信号的日志。
    /// 修改的不太需要。注意记录信号本身的大行为，比如新增了，删除了，关联了，审核了等
    /// </summary>
    [SugarTable(TableName = "ec_wire_group_log")]
    public class ec_wire_group_logEntity
    {
        public ec_wire_group_logEntity()
        {
            Create();
        }
        public ec_wire_group_logEntity(Action OperateType, string WireGroupID)
        {
            this.OperateType = OperateType;
            this.WireGroupID = WireGroupID;
            Create();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="OperateType"></param>
        /// <param name="WireGroupID"></param>
        /// <param name="createtime">因为<see cref="ec_Wire_GroupEntity.ActionHistorys"/>的关系，所以时间是有值的</param>
        public ec_wire_group_logEntity(Action OperateType, string WireGroupID, DateTime? createtime)
        {
            this.OperateType = OperateType;
            this.WireGroupID = WireGroupID;
            Create();
            if (createtime != null)
            {
                this.CreateTime = createtime;
            }

        }
        #region 实体成员
        /// <summary>
        /// 操作日志ID
        /// </summary>
        /// <returns></returns>
        [SugarColumn(IsPrimaryKey = true)]
        public string WireGroupLogID { get; set; }
        /// <summary>
        /// 信号ID
        /// </summary>
        /// <returns></returns>
        public string WireGroupID { get; set; }
        /// <summary>
        /// 操作类型
        /// </summary>
        /// <returns></returns>
        [JsonConverter(typeof(StringEnumConverter))]
        public Action OperateType { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        /// <returns></returns>
        public string ExtraMsg { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        /// <returns></returns>
        public string CreateUserID { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        /// <returns></returns>
        public DateTime? CreateTime { get; set; }
        /// <summary>
        /// 更新人
        /// </summary>
        /// <returns></returns>
        public string UpdateUserID { get; set; }
        /// <summary>
        /// 更新时间
        /// </summary>
        /// <returns></returns>
        public DateTime? UpdateTime { get; set; }
        #endregion

        #region 扩展操作
        /// <summary>
        /// 新增调用
        /// </summary>
        public void Create()
        {
            this.WireGroupLogID = Guid.NewGuid().ToString();
            this.CreateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.CreateUserID = userInfo.userId;
        }
        /// <summary>
        /// 编辑调用
        /// </summary>
        /// <param name="keyValue"></param>
        public void Modify(string keyValue)
        {
            this.WireGroupLogID = keyValue;
            this.UpdateTime = Time.MySqlTime;
            UserInfo userInfo = LoginUserInfo.Get();
            this.UpdateUserID = userInfo.userId;
        }
        #endregion

        #region 扩展字段
        /// <summary> 
        /// 创建人名称 
        /// </summary> 
        /// <returns></returns> 
        [SugarColumn(IsIgnore = true)]
        public string CreateUserName { get; set; }
        #endregion
    }
}

